#include "GameGrid.h"

CGameGrid::CGameGrid()
	:m_nX(0)
	, m_nY(0)
	, m_nGridWidth(50)
{
}

CGameGrid::~CGameGrid()
{
}

bool CGameGrid::init()
{
	if (!Node::init())
	{
		return false;
	}
	SpriteFrameCache* pCache = SpriteFrameCache::getInstance();
	pCache->addSpriteFramesWithFile("sprites/effects.plist");

	return true;
}

void CGameGrid::initGrid(int nX, int nY)
{
	m_nX = nX;
	m_nY = nY;

	for (int i = 0; i < m_nX; i++)
	{
		for (int j = 0; j < m_nY; j++)
		{
			Sprite* pGrid = Sprite::createWithSpriteFrameName("grid.png");
			pGrid->setContentSize(Size(m_nGridWidth, m_nGridWidth));
			pGrid->setPosition(Vec2(i*m_nGridWidth, j*m_nGridWidth));
			m_pVecGrid.pushBack(pGrid);
			this->addChild(pGrid);
		}
	}
}

float CGameGrid::getHeight()
{
	return m_nGridWidth*m_nY;
}

float CGameGrid::getWidth()
{
	return m_nGridWidth*m_nX;
}
